// CmdManage.cpp: implementation of the CCmdManage class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CMDManage.h"
//#include "Function.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif



typedef UCHAR Comdata[20];

struct vMyComdata{
	Comdata m_data;

	void operator = (const vMyComdata &__D)
	{
		m_data[0] = __D.m_data[0];
		m_data[1] = __D.m_data[1];
		m_data[2] = __D.m_data[2];
		m_data[3] = __D.m_data[3];
		m_data[4] = __D.m_data[4];
		m_data[5] = __D.m_data[5];
		m_data[6] = __D.m_data[6];
		m_data[7] = __D.m_data[7];
		m_data[8] = __D.m_data[8];
		m_data[9] = __D.m_data[9];
		m_data[10] = __D.m_data[10];
		m_data[11] = __D.m_data[11];
		m_data[12] = __D.m_data[12];
		m_data[13] = __D.m_data[13];
		m_data[14] = __D.m_data[14];
		m_data[15] = __D.m_data[15];
		m_data[16] = __D.m_data[16];
		m_data[17] = __D.m_data[17];
		m_data[18] = __D.m_data[18];
		m_data[19] = __D.m_data[19];
	}

};

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCmdManage::CCmdManage()
{
	InitCmdList();
}
////////////////////////////////////////////////////////////////////////////////////
CCmdManage::~CCmdManage()
{
}
////////////////////////////////////////////////////////////////////////////////////

void CCmdManage::InitCmd(int Index,CString CMD,short Type,short ReadOnly,
						 double Value,double DefaultValue,short Param)
{
#ifdef _WIN32_WCE
	wcscpy(CmdList[Index].cAryName,CMD);
#else
	strcpy(CmdList[Index].cAryName,CMD);
#endif
	CmdList[Index].Type = Type;
	CmdList[Index].ReadOnly = ReadOnly;
	CmdList[Index].DefaultValue= DefaultValue;
	CmdList[Index].Value = Value;
	CmdList[Index].Param = Param;
}
////////////////////////////////////////////////////////////////////////////////////

void CCmdManage::InitCmdList()
{
	memset(CmdList,0,sizeof(TCommand)*MAX_COMMAND_NUM);

	InitCmd(	CMD_ABSOFFSET,	_T("ABSOFFSET"),			DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ACC,	_T("ACC"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ACTIVE	,	_T("ACTIVE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ADDR	,	_T("ADDR"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN1	,	_T("ANIN1"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN1DB	,	_T("ANIN1DB"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN1ISCALE	,	_T("ANIN1ISCALE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN1LPFHZ	,	_T("ANIN1LPFHZ"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN1OFFSET	,	_T("ANIN1OFFSET"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN1VSCALE	,	_T("ANIN1VSCALE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN1ZERO	,	_T("ANIN1ZERO"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN2	,	_T("ANIN2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN2DB	,	_T("ANIN2DB"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN2ISCALE	,	_T("ANIN2ISCALE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN2LPFHZ	,	_T("ANIN2LPFHZ"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN2MODE	,	_T("ANIN2MODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN2OFFSET	,	_T("ANIN2OFFSET"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANIN2ZERO	,	_T("ANIN2ZERO"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANOUT	,	_T("ANOUT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANOUTCMD	,	_T("ANOUTCMD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANOUTISCALE	,	_T("ANOUTISCALE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANOUTLIM	,	_T("ANOUTLIM"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANOUTMODE	,	_T("ANOUTMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ANOUTVSCALE	,	_T("ANOUTVSCALE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_AUTOHOME	,	_T("AUTOHOME"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_BAUDRATE	,	_T("BAUDRATE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_BW	,	_T("BW"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_CANBITRATE	,	_T("CANBITRATE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_CHECKSUM	,	_T("CHECKSUM"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_CLEARFAULTS	,	_T("CLEARFAULTS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_CLTUNE	,	_T("CLTUNE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_CLTUNEST	,	_T("CLTUNEST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_CLVD	,	_T("CLVD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_CLVQ	,	_T("CLVQ"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_COMMODE	,	_T("COMMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_CONFIG	,	_T("CONFIG"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DEC	,	_T("DEC"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DECDIST	,	_T("DECDIST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DECDIST2	,	_T("DECDIST2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DECSTOP	,	_T("DECSTOP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DECSTOPTIME	,	_T("DECSTOPTIME"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DICONT	,	_T("DICONT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DIPEAK	,	_T("DIPEAK"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DIR	,	_T("DIR"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DISMODE	,	_T("DISMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DISPLAYTEST	,	_T("DISPLAYTEST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DISSPEED	,	_T("DISSPEED"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DISTIME	,	_T("DISTIME"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DRIVENAME	,	_T("DRIVENAME"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DRIVESCRIPT	,	_T("DRIVESCRIPT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DRIVESCRIPTST	,	_T("DRIVESCRIPTST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DRIVETEMP	,	_T("DRIVETEMP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_DUMP	,	_T("DUMP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ECHO	,	_T("ECHO"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ELECTANGLE	,	_T("ELECTANGLE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_EMBER	,	_T("EMBER"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_EN	,	_T("EN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ENCOUTMODE	,	_T("ENCOUTMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ENCOUTRES	,	_T("ENCOUTRES"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ENCOUTZPOS	,	_T("ENCOUTZPOS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ESTMOTORPARAM	,	_T("ESTMOTORPARAM"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ESTMOTORPARAMST	,	_T("ESTMOTORPARAMST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ESTOPILIM	,	_T("ESTOPILIM"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FACTORYRESTORE	,	_T("FACTORYRESTORE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FBGDS	,	_T("FBGDS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FBGMS	,	_T("FBGMS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FBITIDX	,	_T("FBITIDX"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FBITPRD	,	_T("FBITPRD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FBSCALE	,	_T("FBSCALE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FEEDBACKTYPE	,	_T("FEEDBACKTYPE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FILTHZ1	,	_T("FILTHZ1"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FILTHZ2	,	_T("FILTHZ2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FILTMODE	,	_T("FILTMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FLT	,	_T("FLT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FLTHIST	,	_T("FLTHIST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FLTHISTCLR	,	_T("FLTHISTCLR"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FOLD	,	_T("FOLD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FRICINEG	,	_T("FRICINEG"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FRICIPOS	,	_T("FRICIPOS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FRICNVHYST	,	_T("FRICNVHYST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_FRICPVHYST	,	_T("FRICPVHYST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GEAR	,	_T("GEAR"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GEARACCTHRESH	,	_T("GEARACCTHRESH"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GEARFILTAFF	,	_T("GEARFILTAFF"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GEARFILTMODE	,	_T("GEARFILTMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GEARFILTT1	,	_T("GEARFILTT1"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GEARFILTT2	,	_T("GEARFILTT2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GEARFILTVELFF	,	_T("GEARFILTVELFF"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GEARIN	,	_T("GEARIN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GEARINMODE	,	_T("GEARINMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GEARLIMITSMODE	,	_T("GEARLIMITSMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GEARMODE	,	_T("GEARMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GEAROUT	,	_T("GEAROUT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GET	,	_T("GET"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GETMODE	,	_T("GETMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_GETREC	,	_T("GETREC"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HALLS	,	_T("HALLS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HALLSINV	,	_T("HALLSINV"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HALLSTYPE	,	_T("HALLSTYPE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HCFB	,	_T("HCFB"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HCFB1	,	_T("HCFB1"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HCFB2	,	_T("HCFB2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HCICMD	,	_T("HCICMD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HCICMD1	,	_T("HCICMD1"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HCICMD2	,	_T("HCICMD2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HIFACEREAD	,	_T("HIFACEREAD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HOLD	,	_T("HOLD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HOMEACC	,	_T("HOMEACC"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HOMECMD	,	_T("HOMECMD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HOMEIHARDSTOP	,	_T("HOMEIHARDSTOP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HOMEOFFSET	,	_T("HOMEOFFSET"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HOMESPEED1	,	_T("HOMESPEED1"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HOMESPEED2	,	_T("HOMESPEED2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HOMESTATE	,	_T("HOMESTATE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HOMETYPE	,	_T("HOMETYPE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HWPEXT	,	_T("HWPEXT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HWPEXTCNTRLR	,	_T("HWPEXTCNTRLR"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HWPEXTMACHN	,	_T("HWPEXTMACHN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_HWPOS	,	_T("HWPOS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_I	,	_T("I"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ICMD	,	_T("ICMD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ID	,	_T("ID"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IFFLPFHZ	,	_T("IFFLPFHZ"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IFOLD	,	_T("IFOLD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IFOLDFTHRESH	,	_T("IFOLDFTHRESH"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IFOLDWTHRESH	,	_T("IFOLDWTHRESH"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IGRAV	,	_T("IGRAV"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ILIM	,	_T("ILIM"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ILIMACT	,	_T("ILIMACT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IMAX	,	_T("IMAX"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IN	,	_T("IN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_INDEXFIND	,	_T("INDEXFIND"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_INDEXFINDST	,	_T("INDEXFINDST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_INDEXPFB	,	_T("INDEXPFB"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_INERTIAIDENTEN	,	_T("INERTIAIDENTEN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_INERTIAIDENTEST	,	_T("INERTIAIDENTEST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_INFO	,	_T("INFO"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ININV	,	_T("ININV"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_INMODE	,	_T("INMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_INPOS	,	_T("INPOS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_INPUTS	,	_T("INPUTS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IQ	,	_T("IQ"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IQCMD	,	_T("IQCMD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ISTOP	,	_T("ISTOP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IU	,	_T("IU"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IUOFFSET	,	_T("IUOFFSET"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IV	,	_T("IV"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IVOFFSET	,	_T("IVOFFSET"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_IZERO	,	_T("IZERO"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_J	,	_T("J"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_K	,	_T("K"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KCBEMF	,	_T("KCBEMF"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KCD	,	_T("KCD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KCDQCOMP	,	_T("KCDQCOMP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KCFF	,	_T("KCFF"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KCI	,	_T("KCI"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KCIMEMD	,	_T("KCIMEMD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KCIMEMQ	,	_T("KCIMEMQ"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KCMODE	,	_T("KCMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KCP	,	_T("KCP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KNLD	,	_T("KNLD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KNLI	,	_T("KNLI"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KNLIDV	,	_T("KNLIDV"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KNLIINT	,	_T("KNLIINT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KNLIV	,	_T("KNLIV"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KNLP	,	_T("KNLP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KNLUSERGAIN	,	_T("KNLUSERGAIN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KPAFRC	,	_T("KPAFRC"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KPAFRV	,	_T("KPAFRV"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KPD	,	_T("KPD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KPE	,	_T("KPE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KPI	,	_T("KPI"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KPISATIN	,	_T("KPISATIN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KPISATOUT	,	_T("KPISATOUT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KPP	,	_T("KPP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KPVFR	,	_T("KPVFR"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KVFR	,	_T("KVFR"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KVI	,	_T("KVI"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_KVP	,	_T("KVP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_LIMSWITCHNEG	,	_T("LIMSWITCHNEG"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_LIMSWITCHPOS	,	_T("LIMSWITCHPOS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_LIST	,	_T("LIST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_LMJR	,	_T("LMJR"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_LOAD	,	_T("LOAD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MB	,	_T("MB"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MBST	,	_T("MBST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MECHANGLE	,	_T("MECHANGLE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MEMBIT	,	_T("MEMBIT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MEMF	,	_T("MEMF"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MEML	,	_T("MEML"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MEMQ	,	_T("MEMQ"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MEMW	,	_T("MEMW"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MENCRES	,	_T("MENCRES"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MENCTYPE	,	_T("MENCTYPE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MENCZPOS	,	_T("MENCZPOS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MFBDIR	,	_T("MFBDIR"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MFBMODE	,	_T("MFBMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MFOLD	,	_T("MFOLD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MFOLDD	,	_T("MFOLDD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MFOLDDIS	,	_T("MFOLDDIS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MFOLDR	,	_T("MFOLDR"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MFOLDT	,	_T("MFOLDT"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MICONT	,	_T("MICONT"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MIFOLD	,	_T("MIFOLD"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MIFOLDFTHRESH	,	_T("MIFOLDFTHRESH"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MIFOLDWTHRESH	,	_T("MIFOLDWTHRESH"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MIPEAK	,	_T("MIPEAK"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MJ	,	_T("MJ"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MKF	,	_T("MKF"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MKT	,	_T("MKT"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_ML	,	_T("ML"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MLGAINC	,	_T("MLGAINC"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MLGAINP	,	_T("MLGAINP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MMASS	,	_T("MMASS"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MOTORCOMMTYPE	,	_T("MOTORCOMMTYPE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOTORNAME	,	_T("MOTORNAME"),				DATA_TYPE_STRING,	0,	0,	0,	0);
	InitCmd(	CMD_MOTORPHASESCAN	,	_T("MOTORPHASESCAN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOTORSETUP	,	_T("MOTORSETUP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOTORSETUPST	,	_T("MOTORSETUPST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOTORTYPE	,	_T("MOTORTYPE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOVEABS	,	_T("MOVEABS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOVEINC	,	_T("MOVEINC"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOVEINCCOUNTER	,	_T("MOVEINCCOUNTER"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOVEINCDELAY	,	_T("MOVEINCDELAY"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOVEINCDIST1	,	_T("MOVEINCDIST1"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOVEINCDIST2	,	_T("MOVEINCDIST2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOVEINCSPEED1	,	_T("MOVEINCSPEED1"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOVEINCSPEED2	,	_T("MOVEINCSPEED2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOVESMOOTHAVG	,	_T("MOVESMOOTHAVG"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOVESMOOTHLPFHZ	,	_T("MOVESMOOTHLPFHZ"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MOVESMOOTHMODE	,	_T("MOVESMOOTHMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MPHASE	,	_T("MPHASE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MPITCH	,	_T("MPITCH"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MPOLES	,	_T("MPOLES"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MR	,	_T("MR"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MRESPOLES	,	_T("MRESPOLES"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MRT	,	_T("MRT"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MSGPROMPT	,	_T("MSGPROMPT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MSPEED	,	_T("MSPEED"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_MTANGLC	,	_T("MTANGLC"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MTANGLP	,	_T("MTANGLP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MVANGLF	,	_T("MVANGLF"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_MVANGLH	,	_T("MVANGLH"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLAFFLPFHZ	,	_T("NLAFFLPFHZ"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLANTIVIBGAIN	,	_T("NLANTIVIBGAIN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLANTIVIBGAIN2	,	_T("NLANTIVIBGAIN2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLANTIVIBHZ	,	_T("NLANTIVIBHZ"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLANTIVIBHZ2	,	_T("NLANTIVIBHZ2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLANTIVIBKNLD	,	_T("NLANTIVIBKNLD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLANTIVIBLMJR	,	_T("NLANTIVIBLMJR"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLANTIVIBN	,	_T("NLANTIVIBN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLANTIVIBSHARP	,	_T("NLANTIVIBSHARP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLANTIVIBSHARP2	,	_T("NLANTIVIBSHARP2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLFILTDAMPING	,	_T("NLFILTDAMPING"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLFILTT1	,	_T("NLFILTT1"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLMAXGAIN	,	_T("NLMAXGAIN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLNOTCHBW	,	_T("NLNOTCHBW"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLNOTCHCENTER	,	_T("NLNOTCHCENTER"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLNOTCH2BW	,	_T("NLNOTCH2BW"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLNOTCH2CENTER	,	_T("NLNOTCH2CENTER"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLPEAFF	,	_T("NLPEAFF"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLPEDFFRATIO	,	_T("NLPEDFFRATIO"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLSETTLEMODE	,	_T("NLSETTLEMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLTUNE	,	_T("NLTUNE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLTUNEPARAM	,	_T("NLTUNEPARAM"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLTUNEST	,	_T("NLTUNEST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_NLTUNETIME	,	_T("NLTUNETIME"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_OPMODE	,	_T("OPMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_OUT	,	_T("OUT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_OUTILVL1	,	_T("OUTILVL1"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_OUTILVL2	,	_T("OUTILVL2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_OUTINV	,	_T("OUTINV"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_OUTMODE	,	_T("OUTMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_OUTPLVL1	,	_T("OUTPLVL1"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_OUTPLVL2	,	_T("OUTPLVL2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_OUTPUTS	,	_T("OUTPUTS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_OUTVLVL1	,	_T("OUTVLVL1"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_OUTVLVL2	,	_T("OUTVLVL2"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_OVTHRESH	,	_T("OVTHRESH"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PASSWORD	,	_T("PASSWORD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PCMD	,	_T("PCMD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PDEN	,	_T("PDEN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PE	,	_T("PE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PEINPOS	,	_T("PEINPOS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PEINPOSTIME	,	_T("PEINPOSTIME"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PELOOP	,	_T("PELOOP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PEMAX	,	_T("PEMAX"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PFB	,	_T("PFB"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PFBBACKUP	,	_T("PFBBACKUP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PFBBACKUPMODE	,	_T("PFBBACKUPMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PFBOFFSET	,	_T("PFBOFFSET"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PHASEFIND	,	_T("PHASEFIND"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PHASEFINDANGLE	,	_T("PHASEFINDANGLE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PHASEFINDGAIN	,	_T("PHASEFINDGAIN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PHASEFINDI	,	_T("PHASEFINDI"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PHASEFINDMODE	,	_T("PHASEFINDMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PHASEFINDST	,	_T("PHASEFINDST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PHASEFINDTIME	,	_T("PHASEFINDTIME"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PNUM	,	_T("PNUM"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_POSCONTROLMODE	,	_T("POSCONTROLMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_POSLIMMODE	,	_T("POSLIMMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_POSLIMNEG	,	_T("POSLIMNEG"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_POSLIMPOS	,	_T("POSLIMPOS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PRBFRQ	,	_T("PRBFRQ"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PRBMODE	,	_T("PRBMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PRBPARAM	,	_T("PRBPARAM"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PTPTE	,	_T("PTPTE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PTPVCMD	,	_T("PTPVCMD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PWMFRQ	,	_T("PWMFRQ"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_PWMSATRATIO	,	_T("PWMSATRATIO"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_READY	,	_T("READY"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_RECDONE	,	_T("RECDONE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_RECING	,	_T("RECING"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_RECLIST	,	_T("RECLIST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_RECOFF	,	_T("RECOFF"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_RECORD	,	_T("RECORD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_RECRDY	,	_T("RECRDY"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_RECTRIG	,	_T("RECTRIG"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_RECTRIGLIST	,	_T("RECTRIGLIST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_RELAY	,	_T("RELAY"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_RELAYMODE	,	_T("RELAYMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_REMOTE	,	_T("REMOTE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_RESAMPLRANGE	,	_T("RESAMPLRANGE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_RESBW	,	_T("RESBW"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_SAVE	,	_T("SAVE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_SININIT	,	_T("SININIT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_SININITMODE	,	_T("SININITMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_SININITST	,	_T("SININITST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_SINPARAM	,	_T("SINPARAM"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_SLEKFMKT	,	_T("SLEKFMKT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_SLEKFML	,	_T("SLEKFML"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_SLEKFMR	,	_T("SLEKFMR"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_SLTFORCED	,	_T("SLTFORCED"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ST	,	_T("ST"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_STALLTIME	,	_T("STALLTIME"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_STALLVEL	,	_T("STALLVEL"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_STAT	,	_T("STAT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_STATUS	,	_T("STATUS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_STEP	,	_T("STEP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_STOP	,	_T("STOP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_STOPPED	,	_T("STOPPED"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_SWEN	,	_T("SWEN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_SWENMODE	,	_T("SWENMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_SYNCSOURCE	,	_T("SYNCSOURCE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_T	,	_T("T"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_TF	,	_T("TF"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_THERM	,	_T("THERM"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_THERMCLEARLEVEL	,	_T("THERMCLEARLEVEL"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_THERMODE	,	_T("THERMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_THERMREADOUT	,	_T("THERMREADOUT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_THERMTIME	,	_T("THERMTIME"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_THERMTRIPLEVEL	,	_T("THERMTRIPLEVEL"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_THERMTYPE	,	_T("THERMTYPE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_TMTEMP	,	_T("TMTEMP"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_TMTURNRESET	,	_T("TMTURNRESET"),				DATA_TYPE_FLOAT,	0,	0,	0,	0);
	InitCmd(	CMD_TRUN	,	_T("TRUN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_UNITSLINACC	,	_T("UNITSLINACC"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_UNITSLINPOS	,	_T("UNITSLINPOS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_UNITSLINVEL	,	_T("UNITSLINVEL"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_UNITSROTACC	,	_T("UNITSROTACC"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_UNITSROTPOS	,	_T("UNITSROTPOS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_UNITSROTVEL	,	_T("UNITSROTVEL"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_UVMODE	,	_T("UVMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_UVRECOVER	,	_T("UVRECOVER"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_UVTHRESH	,	_T("UVTHRESH"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_UVTIME	,	_T("UVTIME"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_V	,	_T("V"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VBUS	,	_T("VBUS"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VBUSREADOUT	,	_T("VBUSREADOUT"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VCMD	,	_T("VCMD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VD	,	_T("VD"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VE	,	_T("VE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VELCONTROLMODE	,	_T("VELCONTROLMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VELDESIGN	,	_T("VELDESIGN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VELFILTFRQ	,	_T("VELFILTFRQ"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VELFILTMODE	,	_T("VELFILTMODE"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VER	,	_T("VER"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VF	,	_T("VF"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VFI	,	_T("VFI"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VH	,	_T("VH"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VLIM	,	_T("VLIM"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VMAX	,	_T("VMAX"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_VR	,	_T("VR"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_WNSERR	,	_T("WNSERR"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_WRN	,	_T("WRN"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_XENCRES	,	_T("XENCRES"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd(	CMD_ZERO	,	_T("ZERO"),				DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNE	 , _T("HDTUNE"),	DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNEACC	, _T("HDTUNEACC"),		DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNEACTIVE	, _T("HDTUNEACTIVE"),	DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNECYCLE	 , _T("HDTUNECYCLE"),		DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNEDIST	 , _T("HDTUNEDIST"),		DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNEEFFORT	 , _T("HDTUNEEFFORT"),		DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNEEFFORTMAX	 , _T("HDTUNEEFFORTMAX"),		DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNEENCSHR	 , _T("HDTUNEENCSHR"),		DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNELMJR	 , _T("HDTUNELMJR"),		DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNENLFILT	 , _T("HDTUNENLFILT"),		DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNENLPEAFF	 , _T("HDTUNENLPEAFF"),		DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNEREFEN	 , _T("HDTUNEREFEN"),		DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNEREFERENCE	 , _T("HDTUNEREFERENCE"),		DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNEST	 , _T("HDTUNEST"),		DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNESTIFF	 , _T("HDTUNESTIFF"),		DATA_TYPE_INT,	0,	0,	0,	0);
	InitCmd( 	CMD_HDTUNEVCRUISE	 , _T("HDTUNEVCRUISE"),		DATA_TYPE_INT,	0,	0,	0,	0);
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// FUNCTION: ConnectToDevice
// REMARKS: Connect to the spicific device
// INPUT:stxDevice---device
// OUTPUT: 0---success,other---fail
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
short CCmdManage::ConnectToDevice(short iPort,int baud,int databits,int stopbits,int parity)
{
	short rtn;
	TCHAR  portName[16];
	
	if(INVALID_HANDLE_VALUE!=SerialPort.m_hComm)
		SerialPort.ClosePort();

#ifdef _WIN32_WCE
	wsprintf(portName,_T("COM%d:"),iPort);
	rtn = SerialPort.OpenPort(portName,baud,databits,stopbits,parity);
	if(rtn)
		return RTN_CMD_OK;
#else
	wsprintf(portName,_T("COM%d"),iPort);
	rtn = SerialPort.OpenPort(portName,baud,);
	if(rtn)
		return RTN_CMD_OK;
#endif

	return RTN_CMD_FAIL;
}
////////////////////////////////////////////////////////////////////////////////////
short CCmdManage::DisConnect()
{
	if(SerialPort.ClosePort())
		return RTN_CMD_OK;
	else
		return RTN_CMD_FAIL;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// FUNCTION: CheckReturnStr
// REMARKS: Check if the rtnStr contain string "-->",if yes,Trim it
// INPUT:rtnStr---string to check
// OUTPUT: 0---success,other---fail
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
short CCmdManage::CheckReturnStr(char *rtnStr)
{
	int i;
	int len;
	char *strTemp;

	len = strlen(rtnStr);

	for(i=len;i>0;i--)
	{
		if(*(rtnStr+i) == '>') 
		{
			if(i < 2)
				return RTN_CMD_FAIL;

			if((*(rtnStr+i-1) == '-'))
			{
				*(rtnStr+i-2) = '\0';
				return RTN_CMD_OK;
			}
		}
	}

	return RTN_CMD_FAIL;
}

////////////////////////////////////////////////////////////////////////////////////

short CCmdManage::SwitchToAxis(int iIndex)
{
	if(iIndex > COMMAND_BUFFER_LENGTH)
		return RTN_CMD_PARAM_RANGE;

	sprintf(cmdString,"\\%d\r",iIndex);//\r
	//SerialPort.CleanData();
	//SerialPort.
	//memset(readString,0,COMMAND_BUFFER_LENGTH);
	int len = strlen(cmdString);
	
	SerialPort.WritePort(cmdString,strlen(cmdString));
	dwBytesRead = SerialPort.ReadPort(readString,COMMAND_BUFFER_LENGTH);
	
	if(dwBytesRead > 0) 
		rtn = CheckReturnStr(readString);
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}

////////////////////////////////////////////////////////////////////////////////////

short CCmdManage::GetCmdInt(short Index,short Param,short *Value)
{
	*Value = (short)CmdList[Index].DefaultValue;

	if(NON_SECOND_PARAM==Param)
		sprintf(cmdString,"%s\r",CmdList[Index].cAryName);
	else
		sprintf(cmdString,"%s %d\r",CmdList[Index].cAryName,Param);

	SerialPort.WritePort(cmdString,strlen(cmdString));
	dwBytesRead = SerialPort.ReadPort(readString,COMMAND_BUFFER_LENGTH);

	if(dwBytesRead>0) 
	{
		rtn = CheckReturnStr(readString);
		if(RTN_CMD_OK == rtn) 
		{
			char* p=strchr(readString,CHAR_LF);
			if(p!=NULL)
			{
				p++;
				*Value = atoi(p);
			}
		}
	}
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}

////////////////////////////////////////////////////////////////////////////////////

short CCmdManage::GetCmdLong(short Index,long *lValue)
{
	*lValue = (long)CmdList[Index].DefaultValue;

	sprintf(cmdString,"%s\r",CmdList[Index].cAryName);

	SerialPort.WritePort(cmdString,strlen(cmdString));
	dwBytesRead = SerialPort.ReadPort(readString,COMMAND_BUFFER_LENGTH);

	if(dwBytesRead>0) 
	{
		rtn = CheckReturnStr(readString);
		if(RTN_CMD_OK == rtn) 
		{
			char* p=strchr(readString,CHAR_LF);
			if(p!=NULL)
			{
				p++;
				*lValue = atol(p);
			}
		}
	}
	else
		rtn = RTN_CMD_FAIL;


	return rtn;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// FUNCTION: GetCmdDouble
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
short CCmdManage::GetCmdDouble(short Index,double *Value)
{
	*Value = (double)CmdList[Index].DefaultValue;

	sprintf(cmdString,"%s\r",/*CmdList[Index].cAryName*/"PFB");

	SerialPort.WritePort(cmdString,strlen(cmdString));
	dwBytesRead = SerialPort.ReadPort(readString,COMMAND_BUFFER_LENGTH);

	if(dwBytesRead>0) 
	{
		rtn = CheckReturnStr(readString);
		if(RTN_CMD_OK == rtn) 
		{
			char* p=strchr(readString,CHAR_LF);
			if(p!=NULL)
			{
				p++;
				*Value = atof(p);
			}
		}
	}
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Description: Please refer to the description of Function 'GetCmdDouble'
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
short CCmdManage::GetCmdString(short Index,char *pStr,short iLen)
{
	int CmdLength;

	if(iLen > RECEIVE_BUFFER_LENGTH) 
		return RTN_CMD_PARAM_RANGE;

	sprintf(cmdString,"%s\r",CmdList[Index].cAryName);

	CmdLength=strlen(cmdString);
	SerialPort.WritePort(cmdString,CmdLength);
	dwBytesRead = SerialPort.ReadPort(cmdString,CmdLength);
	dwBytesRead = SerialPort.ReadPort(readString,COMMAND_BUFFER_LENGTH);

	if(dwBytesRead>0) 
	{
		rtn = CheckReturnStr(readString);
		if(RTN_CMD_OK == rtn) 
			strcpy(pStr,readString);
	}
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
short CCmdManage::WriteStringToPort(char *WriteBuf)
{
	int CmdLength;

	sprintf(cmdString,"%s\r",WriteBuf);

	CmdLength=strlen(cmdString);
	SerialPort.WritePort(cmdString,CmdLength);
	dwBytesRead=SerialPort.ReadPort(readString,CmdLength);

	if(dwBytesRead > 0) 
		rtn = CheckReturnStr(readString);
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

CString CCmdManage::ReadDataToString(short Length)
{
	int dwBytesRead=0;
	char readString[RECEIVE_BUFFER_LENGTH];
	CString ReadBuf;
	CString Temp;
	int Pos;

	ReadBuf.Empty();

	if(Length>0)
	{
		if(Length<=RECEIVE_BUFFER_LENGTH)
		{
			dwBytesRead=SerialPort.ReadPort(readString,Length);
			ReadBuf=readString;
		}
	}
	else
	{
		do
		{
			dwBytesRead=SerialPort.ReadPort(readString,RECEIVE_BUFFER_LENGTH);
			
			if(dwBytesRead>0)
			{
				rtn=CheckReturnStr(readString);
				if(dwBytesRead<RECEIVE_BUFFER_LENGTH-1)
					ReadBuf+=readString;
				else
				{
					Temp=readString;
				#ifdef _DEBUG
					ReadBuf+=Temp.Left(Temp.GetLength()-2);
				#else
					ReadBuf+=Temp.Left(Temp.GetLength()-3);
				#endif
				}
			}
			else
				rtn = RTN_CMD_FAIL;
		}while(dwBytesRead>0);
	}

	return ReadBuf;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Description: Please refer to the description of Function 'GetCmdDouble'
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
short CCmdManage::SetCmd(short Index)
{
	int CmdLength;

	sprintf(cmdString,"%s\r",CmdList[Index].cAryName);

	CmdLength=strlen(cmdString);
	SerialPort.WritePort(cmdString,CmdLength);
	dwBytesRead = SerialPort.ReadPort(readString,CmdLength);

	if(dwBytesRead>0) 
		rtn = CheckReturnStr(cmdString);
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Description: Please refer to the description of Function 'GetCmdDouble'
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
short CCmdManage::SetCmdInt(short Index,short param,short iValue)
{
	if(param==NON_SECOND_PARAM)
	   sprintf(cmdString,"%s %d\r",CmdList[Index].cAryName,iValue);
	else
	   sprintf(cmdString,"%s %d %d\r",CmdList[Index].cAryName,param,iValue);

	SerialPort.WritePort(cmdString,strlen(cmdString));
	dwBytesRead = SerialPort.ReadPort(cmdString,COMMAND_BUFFER_LENGTH);

	if(dwBytesRead>0) 
		rtn = CheckReturnStr(cmdString);
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Description: Please refer to the description of Function 'GetCmdDouble'
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
short CCmdManage::SetCmdLong(short Index,long lValue)
{
	sprintf(cmdString,"%s %ld\r",CmdList[Index].cAryName,lValue);

	SerialPort.WritePort(cmdString,strlen(cmdString));
	dwBytesRead = SerialPort.ReadPort(cmdString,COMMAND_BUFFER_LENGTH);

	if(dwBytesRead>0) 
		rtn = CheckReturnStr(cmdString);
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Description: Please refer to the description of Function 'GetCmdDouble'
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
short CCmdManage::SetCmdDouble(short Index,double fValue)
{
	sprintf(cmdString,"%s %.3f\r",CmdList[Index].cAryName,fValue);

	SerialPort.WritePort(cmdString,strlen(cmdString));
	dwBytesRead = SerialPort.ReadPort(cmdString,COMMAND_BUFFER_LENGTH);

	if(dwBytesRead>0) 
		rtn = CheckReturnStr(cmdString);
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Description: Please refer to the description of Function 'GetCmdDouble'
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
short CCmdManage::SetCmdString(short Index,char *pStr,short iLen)
{
	if (iLen > COMMAND_BUFFER_LENGTH) 
		return RTN_CMD_PARAM_RANGE;

	sprintf(cmdString,"%s %s\r",CmdList[Index].cAryName,pStr);

	SerialPort.WritePort(cmdString,strlen(cmdString));
	dwBytesRead = SerialPort.ReadPort(cmdString,COMMAND_BUFFER_LENGTH);
	
	if(dwBytesRead>0) 
		rtn = CheckReturnStr(cmdString);
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}

////////////////////////////////////////////////////////////////////////////////////

short CCmdManage::GetCmdUInt(short Index,unsigned short *Value)
{
	*Value = (unsigned long)CmdList[Index].DefaultValue;

	sprintf(cmdString,"%s\r",CmdList[Index].cAryName);

	SerialPort.WritePort(cmdString,strlen(cmdString));
	dwBytesRead = SerialPort.ReadPort(readString,COMMAND_BUFFER_LENGTH);

	if(dwBytesRead>0) 
	{
		rtn = CheckReturnStr(readString);
		if(RTN_CMD_OK == rtn) 
			*Value = atoi(readString);
	}
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}
////////////////////////////////////////////////////////////////////////////////////

short CCmdManage::GetCmdULong(short Index,unsigned long *ulValue)
{
	*ulValue = (unsigned long)CmdList[Index].DefaultValue;

	sprintf(cmdString,"%s\r",CmdList[Index].cAryName);

	SerialPort.WritePort(cmdString,strlen(cmdString));
	dwBytesRead = SerialPort.ReadPort(readString,COMMAND_BUFFER_LENGTH);

	if(dwBytesRead>0) 
	{
		rtn = CheckReturnStr(readString);
		if(RTN_CMD_OK == rtn) 
			*ulValue = atol(readString);
	}
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Description: Please refer to the description of Function 'GetCmdDouble'
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
short CCmdManage::SetCmdUInt(short Index,unsigned short Value)
{
	sprintf(cmdString,"%s %d\r",CmdList[Index].cAryName,Value);

	SerialPort.WritePort(cmdString,strlen(cmdString));
	dwBytesRead = SerialPort.ReadPort(cmdString,COMMAND_BUFFER_LENGTH);

	if(dwBytesRead>0) 
		rtn = CheckReturnStr(cmdString);
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Description: Please refer to the description of Function 'GetCmdDouble'
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
short CCmdManage::SetCmdULong(short Index,unsigned long ulValue)
{
	sprintf(cmdString,"%s %ld\r",CmdList[Index].cAryName,ulValue);

	SerialPort.WritePort(cmdString,strlen(cmdString));
	dwBytesRead = SerialPort.ReadPort(cmdString,COMMAND_BUFFER_LENGTH);

	if(dwBytesRead>0) 
		rtn = CheckReturnStr(cmdString);
	else
		rtn = RTN_CMD_FAIL;

	return rtn;
}
unsigned short CCmdManage::Crc16(unsigned char* data , unsigned char length)
{          
	unsigned char i = 0;            
	unsigned short crc = 0xffff;
	while(length--)
	{
		crc ^= *data++;
		for(i = 0; i < 8; i++)
		{
			if(crc & 0x01)  
			{
				crc = (crc >> 1) ^ 0xa001; 	// Polynomial: x^16 + x^15 + x^2 + 1 (0xa001)
			}
			else
			{
				crc = crc >> 1;
			}
		}
	}
	return crc;
}

short CCmdManage::Write16bit(short iAxisNo, unsigned short iAddr, short iVal)
{
	vMyComdata aucDataWrite;
	aucDataWrite.m_data[0] = iAxisNo;
	aucDataWrite.m_data[1] = 0x06;

	aucDataWrite.m_data[3] = 0xFF&iAddr;
	iAddr &= 0xFF00;
	iAddr >>=8;
	aucDataWrite.m_data[2] = 0xFF&iAddr;

	aucDataWrite.m_data[5] = 0xFF&iVal; 
	iVal &= 0xFF00;
	iVal >>=8;
	aucDataWrite.m_data[4] = 0xFF&iVal; 

	unsigned int usCrc = Crc16(aucDataWrite.m_data,6);

	aucDataWrite.m_data[6] = usCrc&0xFF;
	aucDataWrite.m_data[7] = (0xFF00 & usCrc)>>8;

	ZeroMemory(cmdString,sizeof(cmdString));
	memcpy(cmdString,aucDataWrite.m_data,sizeof(aucDataWrite.m_data));
	long stringlength = strlen(cmdString);

	long dwBytesWrite = SerialPort.WritePort(cmdString,8);

	if (dwBytesWrite != 8)
	{
		return -1;
	}

	char aucDataRead[32];
	ZeroMemory(aucDataRead,sizeof(aucDataRead));
	dwBytesRead = SerialPort.ReadPort(aucDataRead,sizeof(aucDataRead));

	return RTN_CMD_OK;
}

short CCmdManage::WriteCmd10(short iAxisNo, unsigned short iAddr, long iVal)
{
	vMyComdata aucDataWrite;
	aucDataWrite.m_data[0] = iAxisNo;
	aucDataWrite.m_data[1] = 0x10;

	aucDataWrite.m_data[3] = 0xFF&iAddr;
	iAddr &= 0xFF00;
	iAddr >>=8;
	aucDataWrite.m_data[2] = 0xFF&iAddr;

	aucDataWrite.m_data[4] = 0x0;
	aucDataWrite.m_data[5] = 0x02;


	aucDataWrite.m_data[6] = 0x04;

	unsigned long val = iVal&0xFFFF0000;
	val >>= 16;
	aucDataWrite.m_data[8] = 0xFF&val;
	val &= 0xFF00;
	val >>= 8;
	aucDataWrite.m_data[7] = 0xFF&val;

	val = iVal&0xFFFF;
	aucDataWrite.m_data[10] = 0xFF&val; 
	val &= 0xFF00;
	val >>=8;
	aucDataWrite.m_data[9] = 0xFF&val; 

	unsigned int usCrc = Crc16(aucDataWrite.m_data,11);

	aucDataWrite.m_data[11] = usCrc&0xFF;
	aucDataWrite.m_data[12] = (0xFF00 & usCrc)>>8;

	ZeroMemory(cmdString,sizeof(cmdString));
	memcpy(cmdString,aucDataWrite.m_data,sizeof(aucDataWrite.m_data));
	long stringlength = strlen(cmdString);

	long dwBytesWrite = SerialPort.WritePort(cmdString,13);

	if (dwBytesWrite != 13)
	{
		return -1;
	}

	char aucDataRead[32];
	ZeroMemory(aucDataRead,sizeof(aucDataRead));
	dwBytesRead = SerialPort.ReadPort(aucDataRead,sizeof(aucDataRead));

	return RTN_CMD_OK;
}

short CCmdManage::Read16bit(short iAxisNo, unsigned short iAddr, short *iVal)
{
	*iVal = 0.;

	vMyComdata aucDataWrite;
	aucDataWrite.m_data[0] = iAxisNo;
	aucDataWrite.m_data[1] = 4;

	aucDataWrite.m_data[3] = 0xFF&iAddr;
	iAddr &= 0xFF00;
	iAddr >>=8;
	aucDataWrite.m_data[2] = 0xFF&iAddr;

	aucDataWrite.m_data[4] = 0; 
	aucDataWrite.m_data[5] = 0x01; 

	unsigned int usCrc = Crc16(aucDataWrite.m_data,6);

	aucDataWrite.m_data[6] = usCrc&0xFF;
	aucDataWrite.m_data[7] = (0xFF00 & usCrc)>>8;

	ZeroMemory(cmdString,sizeof(cmdString));
	memcpy(cmdString,aucDataWrite.m_data,sizeof(aucDataWrite.m_data));
	long stringlength = strlen(cmdString);

	long dwBytesWrite = SerialPort.WritePort(cmdString,8);

	Sleep(20);
	char aucDataRead[32];
	ZeroMemory(aucDataRead,sizeof(aucDataRead));
	dwBytesRead = SerialPort.ReadPort(aucDataRead,sizeof(aucDataRead));
	if (dwBytesRead < 7)
	{
		iVal = 0;
		return -1;
	}

	unsigned int usCrc2 = Crc16((unsigned char*)aucDataRead,5);
	unsigned int GetCrc2 = aucDataRead[6];
	GetCrc2<<=8;
	GetCrc2&=0xFF00;
	GetCrc2|=(aucDataRead[5]&0xFF);

	if (GetCrc2!=usCrc2)
	{
		return -2;
	}

	unsigned short tmpVal = 0;
	tmpVal = aucDataRead[3];
	tmpVal<<=8;
	tmpVal&=0xFF00;
	tmpVal|=(aucDataRead[4]&0xFF);

	*iVal = tmpVal;

	return RTN_CMD_OK;
}

